package com.kaifamiao.demo.d0822;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class DDZ {

    // 玩家
    private List<Player> players = new ArrayList<>();
    // 底牌
    private List<String> dp = new ArrayList<>();
    // 一副牌
    private Poker poker = new Poker();

    private List<String> pokers = poker.getPokers();

    public DDZ(Player player1, Player player2, Player player3){
        Collections.addAll(players, player1, player2, player3);
    }

    public void start(){
        // 洗牌
        poker.shuffle();
        poker.shuffle();
        poker.shuffle();
        // 发牌
        send();
    }

    public void send(){
        for (int i = 0; i < 17; i ++){
            players.get(0).receive(pokers.get(i * 3 + 0));
            players.get(1).receive(pokers.get(i * 3 + 1));
            players.get(2).receive(pokers.get(i * 3 + 2));
        }
        dp.addAll(pokers.subList(51, pokers.size()));
    }

    public List<String> getDp(){
        dp.sort(new PokerComparator());
        return dp;
    }

    public List<Player> getPlayers(){
        return players;
    }
}
